/*******************************************************************************
"SCARCITY WITHOUT LEVIATHAN: The Violent Effects of Cocaine Supply Shortages
in the Mexican Drug War"
J.C. Castillo, D. Mejia, P. Restrepo
*********************************************************************************

This do file produces:
TABLE 5: "Additional time series estimates of the effect of cocaine seizures in 
Colombia on the homicide rate in different subsamples of Mexican municipalities."

The table presents estimates of the interaction between cocaine seizures in Colombia
on the homicide rate for groups of municipalities (with heterogeneous cartel presence
 and PAN support) in Mexico.
 
 Before runnning: set the path to current folder at line 23
*******************************************************************************/

clear all
set matsize 5000
set more off

*Set local folder
local folder /*SET THE PATH TO CURRENT FOLDER HERE*/

*Set working directory
cd `folder'
use dta/CastilloMejiaRestrepo.dta

tab year if  timeTS >= ym(2006,12), gen(yy)
local tscontrols t t2 t3  yy2 yy3 yy4 yy5

gen homicides=homSIMBAD
gen supplyShock=100*log(cocaincCol)


/****************************************/
/********** CARTEL RESULTS **************/
/**********    Panel A     **************/
/****************************************/

/****************************************/
/*******    No cartels: Cols 1-2     ****/
/****************************************/

preserve

keep if nCarteles==0
collapse `tscontrols' supplyShock unemp IGAE (sum) homicides poblacion, by(timeTS)

/*Create dependent variable: log homicide rate*/
gen tasa = homicides/poblacion * 100000 * 12
gen log_tasa=100*log(tasa)	
tsset timeTS

*Column 1*
reg log_tasa supplyShock `tscontrols' if timeTS >= ym(2006,12), robust
estimates store e1

*Column 2*
reg log_tasa l(1/3).log_tasa  supplyShock `tscontrols' if  timeTS >= ym(2006,12), robust
estimates store e2

restore

/****************************************/
/*******    One cartel: Cols 3-4     ****/
/****************************************/
preserve

keep if nCarteles==1
collapse `tscontrols' supplyShock unemp IGAE (sum) homicides poblacion, by(timeTS)

/*Create dependent variable: log homicide rate*/
gen tasa = homicides/poblacion * 100000 * 12
gen log_tasa=100*log(tasa)	
tsset timeTS

*Columns 3*
reg log_tasa supplyShock `tscontrols' if  timeTS >= ym(2006,12), robust
estimates store e3

*Column 4*
reg log_tasa l(1/3).log_tasa  supplyShock `tscontrols' if  timeTS >= ym(2006,12), robust
estimates store e4

restore


/****************************************/
/**** Various cartels: Cols 5-6      ****/
/****************************************/
preserve

keep if eneCarteles==1
collapse `tscontrols' supplyShock unemp IGAE (sum) homicides poblacion, by(timeTS)

/*Create dependent variable: log homicide rate*/
gen tasa = homicides/poblacion * 100000 * 12
gen log_tasa=100*log(tasa)	
tsset timeTS

*Column 7*
reg log_tasa supplyShock `tscontrols' if  timeTS >= ym(2006,12), robust
estimates store e5


*Column 8*
reg log_tasa l(1/3).log_tasa  supplyShock `tscontrols' if  timeTS >= ym(2006,12), robust
estimates store e6

restore

/****************************************/
/******** PAN Support RESULTS ***********/
/**********    Panel B     **************/
/****************************************/

/****************************************/
/*****  Low PAN support: Cols 7-8  *****/
/****************************************/
preserve

keep if dPANsupport==0
collapse `tscontrols' supplyShock unemp IGAE (sum) homicides poblacion, by(timeTS)

/*Create dependent variable: log homicide rate*/
gen tasa = homicides/poblacion * 100000 * 12
gen log_tasa=100*log(tasa)	
tsset timeTS

*Columns 9*
reg log_tasa supplyShock `tscontrols' if  timeTS >= ym(2006,12), robust
estimates store e7

*Column 10*
reg log_tasa l(1/3).log_tasa  supplyShock `tscontrols' if  timeTS >= ym(2006,12), robust
estimates store e8

restore


/****************************************/
/**** High PAN support: Cols 9-10  *****/
/****************************************/
preserve
keep if dPANsupport==1
collapse `tscontrols' supplyShock unemp IGAE (sum) homicides poblacion, by(timeTS)

/*Create dependent variable: log homicide rate*/
gen tasa = homicides/poblacion * 100000 * 12
gen log_tasa=100*log(tasa)	
tsset timeTS

*Columns 11*
reg log_tasa supplyShock `tscontrols' if  timeTS >= ym(2006,12), robust
estimates store e9

*Column 12*
reg log_tasa l(1/3).log_tasa  supplyShock `tscontrols' if  timeTS >= ym(2006,12), robust
estimates store e10

restore

estout e1 e2 e3 e4 e5 e6 e7 e8 e9 e10  using Tables/Table5.tex, style(tex) ///
varlabels(L.log_tasa "log homicide rate $ t-1$" L2.log_tasa "log homicide rate $ t-2$" ///
 L3.log_tasa "log homicide rate $ t-3$" supplyShock "log of seizures in Colombia $ t$") /// 
 cells(b(star fmt(%9.3f)) se(par fmt(%9.3f))) stats(N r2 , fmt(%7.0f  %7.3f) ///
 labels("Observations" "R-squared"))  collabels(none)  eqlabels(none)  keep(L.log_tasa L2.log_tasa L3.log_tasa supplyShock) ///
 order(L.log_tasa L2.log_tasa L3.log_tasa supplyShock)  starlevels(\$^{*}\$ .1 \$^{**}\$ .05 \$^{***}\$ .01) nolabel replace mlabels(none)
